package hrms.interceptor;

import com.alibaba.fastjson.JSONObject;
import hrms.entity.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author jinbin
 * @date 2018-07-08 22:37
 */
@RestControllerAdvice
public class GloablExceptionHandler {
    @ExceptionHandler(Exception.class)
    public Result handleException(Exception e) {
        String msg = e.getMessage();
        if (msg == null || msg.equals("")) {
            msg = "服务器出错";
        }
        return Result.fail().error(msg);
    }
}
